import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/exam/util/ExamUtil.dart';
import 'package:ichinesereader/exam/widgets/BGExamWidget.dart';

import 'BGAPExamController.dart';

// Part 试卷章节， 最高级别的 章节
class BGAPExamSectionPage extends GetView<BGAPExamController> {
  const BGAPExamSectionPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scrollbar(
        thumbVisibility: true,
        child: SingleChildScrollView(
          primary: true,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                  padding: EdgeInsets.all(10), child: Obx(() => ExamUtil.buildHeadInfoWidget(controller.currentQuestionStepTopic.value, context))),
              Padding(padding: const EdgeInsets.only(top: 10, bottom: 10), child: const Divider(height: 2, color: Colors.grey)),
              Padding(
                  padding: const EdgeInsets.only(left: 20, right: 20),
                  child: Obx(() => BGExamWidget(
                      questionItem: controller.currentQuestionStepBody.value,
                      speakActionNum: controller.speakActionNum.value,
                      mode: controller.isTest.value ? BGExamWidgetMode.Test : BGExamWidgetMode.Practice,
                      getAnswer: (fileId) {
                        if (controller.speakActionNum.value == 2) {
                          Get.snackbar('Message'.tr, 'Saved Successfully'.tr, snackPosition: SnackPosition.TOP, duration: Duration(seconds: 2));
                          Future.delayed(const Duration(seconds: 2), () {
                            controller.isNextPageEnable.value ? controller.nextPage() : controller.submitAction();
                            controller.speakActionNum.value = 0;
                          });
                        }
                      })))
            ],
          ),
        ));
  }
}
